/*     */ package com.lmpop.trade.ti_tradestate;
/*     */ 
/*     */ import com.lmpop.frame.QueryList;
/*     */ import com.lmpop.frame.SysMap;
/*     */ import com.lmpop.frame.TradeInterf;
/*     */ import com.lmpop.frame.dao.DbmInterf;
/*     */ import com.lmpop.frame.exp.ApplicationException;
/*     */ import com.lmpop.frame.util.RandomID;
/*     */ import java.util.Hashtable;
/*     */ import java.util.List;
/*     */ 
/*     */ public class Ti_tradestateInfo
/*     */   implements TradeInterf
/*     */ {
/*     */   QueryList queryList;
/*     */ 
/*     */   public Ti_tradestateInfo()
/*     */   {
/*  16 */     this.queryList = new QueryList();
/*     */   }
/*     */ 
/*     */   public SysMap insert(DbmInterf dbmMgr, SysMap map)
/*     */   {
/*  25 */     RandomID randomID = new RandomID();
/*  26 */     String trade_id = randomID.GenTradeId();
/*  27 */     Ti_tradestate ti_tradestate = new Ti_tradestate();
/*  28 */     ti_tradestate.setTrade_id(trade_id);
/*  29 */     ti_tradestate.setInfo_id(map.getString("info_id"));
/*  30 */     ti_tradestate.setTrade_state(map.getString("trade_state"));
/*     */ 
/*  32 */     String result_code = "0";
/*     */     try {
/*  34 */       insert(dbmMgr, ti_tradestate);
/*     */     } catch (ApplicationException e) {
/*  36 */       e.printStackTrace();
/*  37 */       result_code = "1";
/*     */     }
/*  39 */     map.setString("result_code", result_code);
/*  40 */     return map;
/*     */   }
/*     */ 
/*     */   public void insert(DbmInterf dbmMgr, Ti_tradestate ti_tradestate)
/*     */     throws ApplicationException
/*     */   {
/*  49 */     dbmMgr.update("insertTi_tradestate", ti_tradestate);
/*     */   }
/*     */ 
/*     */   public SysMap delete(DbmInterf dbmMgr, SysMap map)
/*     */   {
/*  59 */     String pkid_string = map.getString("pkid");
/*  60 */     String result_code = "0";
/*     */     try {
/*  62 */       if (!pkid_string.equals("")) {
/*  63 */         String[] pkStr = pkid_string.split("\\|");
/*  64 */         for (int i = 0; i < pkStr.length; i++) {
/*  65 */           if (pkStr[i].equals("")) continue; delete(dbmMgr, pkStr[i]);
/*     */         }
/*     */       }
/*     */     } catch (ApplicationException e) {
/*  69 */       e.printStackTrace();
/*  70 */       result_code = "1";
/*     */     }
/*  72 */     map.setString("result_code", result_code);
/*  73 */     return map;
/*     */   }
/*     */ 
/*     */   public void delete(DbmInterf dbmMgr, String pkid)
/*     */     throws ApplicationException
/*     */   {
/*  82 */     dbmMgr.update("deleteTi_tradestate", pkid);
/*     */   }
/*     */ 
/*     */   public SysMap update(DbmInterf dbmMgr, SysMap map)
/*     */   {
/*  91 */     Ti_tradestate ti_tradestate = new Ti_tradestate();
/*  92 */     RandomID randomID = new RandomID();
/*  93 */     String pkid_string = map.getString("pkid");
/*     */ 
/*  96 */     String trade_code = map.getString("state_code");
/*     */ 
/*  98 */     if (trade_code.equals("")) {
/*  99 */       trade_code = map.getString("trade_state");
/*     */     }
/*     */ 
/* 102 */     if (trade_code.equals("ship_none"))
/*     */     {
/* 104 */       trade_code = "1";
/*     */     }
/* 106 */     else if (trade_code.equals("ship_start"))
/*     */     {
/* 108 */       trade_code = "2";
/*     */     }
/* 110 */     else if (trade_code.equals("ship_end"))
/*     */     {
/* 112 */       trade_code = "3";
/*     */     }
/*     */ 
/* 116 */     ti_tradestate.setTrade_state(trade_code);
/*     */ 
/* 118 */     String result_code = "0";
/*     */     try
/*     */     {
/* 121 */       if (!pkid_string.equals("")) {
/* 122 */         String[] pkStr = pkid_string.split("\\|");
/* 123 */         for (int i = 0; i < pkStr.length; i++)
/*     */         {
/* 125 */           ti_tradestate.setInfo_id(pkStr[i]);
/* 126 */           if (pkStr[i].equals(""))
/*     */             continue;
/* 128 */           if (checkIsExist(pkStr[i])) {
/* 129 */             update(dbmMgr, ti_tradestate);
/*     */           } else {
/* 131 */             String trade_id = randomID.GenTradeId();
/* 132 */             ti_tradestate.setTrade_id(trade_id);
/* 133 */             insert(dbmMgr, ti_tradestate);
/*     */           }
/*     */         }
/*     */ 
/*     */       }
/*     */ 
/*     */     }
/*     */     catch (ApplicationException e)
/*     */     {
/* 142 */       e.printStackTrace();
/* 143 */       result_code = "1";
/*     */     }
/* 145 */     map.setString("result_code", result_code);
/* 146 */     return map;
/*     */   }
/*     */ 
/*     */   public void update(DbmInterf dbmMgr, Ti_tradestate ti_tradestate)
/*     */     throws ApplicationException
/*     */   {
/* 155 */     dbmMgr.update("updateTi_tradestate", ti_tradestate);
/*     */   }
/*     */ 
/*     */   public List getListByPage(Object obj, int start, int limit)
/*     */   {
/* 165 */     Hashtable ti_tradestate = (Hashtable)obj;
/* 166 */     if (start == 0)
/* 167 */       start = 0;
/*     */     else {
/* 169 */       start = (start - 1) * limit;
/*     */     }
/* 171 */     ti_tradestate.put("start", Integer.valueOf(start));
/* 172 */     ti_tradestate.put("limit", Integer.valueOf(limit));
/* 173 */     return this.queryList.getList("getListByTi_tradestatePage", ti_tradestate);
/*     */   }
/*     */ 
/*     */   public int getCountByObj(Object obj)
/*     */   {
/* 184 */     Hashtable ti_tradestate = (Hashtable)obj;
/* 185 */     List list = this.queryList.getList("getCountByObjTi_tradestate", ti_tradestate);
/* 186 */     int count = 0;
/* 187 */     if ((list != null) && (list.size() > 0)) {
/* 188 */       Hashtable newsMap = (Hashtable)list.get(0);
/* 189 */       if ((newsMap.get("count") != null) && (!newsMap.get("count").toString().equals(""))) {
/* 190 */         count = Integer.parseInt(newsMap.get("count").toString());
/*     */       }
/*     */     }
/* 193 */     return count;
/*     */   }
/*     */ 
/*     */   public List getListByPk(String pk)
/*     */   {
/* 203 */     return this.queryList.getList("getTi_tradestateByPk", pk);
/*     */   }
/*     */ 
/*     */   public String getTradeStateByID(String info_id)
/*     */   {
/* 213 */     List list = this.queryList.getList("getTradeStateByID", info_id);
/* 214 */     String trade_state = "1";
/* 215 */     if ((list != null) && (list.size() > 0)) {
/* 216 */       Hashtable newsMap = (Hashtable)list.get(0);
/* 217 */       if ((newsMap.get("trade_state") != null) && (!newsMap.get("trade_state").toString().equals(""))) {
/* 218 */         trade_state = newsMap.get("trade_state").toString();
/*     */       }
/*     */     }
/* 221 */     return trade_state;
/*     */   }
/*     */ 
/*     */   public boolean checkIsExist(String info_id)
/*     */   {
/* 231 */     List list = this.queryList.getList("getTradeStateByID", info_id);
/* 232 */     boolean is_exist = false;
/* 233 */     if ((list != null) && (list.size() > 0)) {
/* 234 */       is_exist = true;
/*     */     }
/* 236 */     return is_exist;
/*     */   }
/*     */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.lmpop.trade.ti_tradestate.Ti_tradestateInfo
 * JD-Core Version:    0.6.0
 */